Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read attributes as provided by the event object, and pass on attributes to other event handlers #53

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

mpdude
Copy link
Member

@mpdude mpdude commented Oct 28, 2024

This PR uses the new API introduced in symfony/symfony#46001 to read controller attributes through the ControllerEvent, and to make them available to other event handlers when replacing the controller.

This is necessary when using the Send304IfNotModified attribute in combination with \Symfony\Component\HttpKernel\Attribute\Cache. Without this change, \Symfony\Component\HttpKernel\EventListener\CacheAttributeListener will not set Cache headers accordingly. The result is that you may get 304 Not Modified responses on conditional requests with If-Modified-Since, but these are treated as stale/cache only in the HttpCache and have a Cache-Control: must-revalidate, private header.

@mpdude mpdude merged commit fcabc29 into master Oct 28, 2024
@mpdude mpdude deleted the use-event-attributes branch October 28, 2024 17:44
MalteWunsch added a commit to webfactory/WebfactoryHttpCacheBundle that referenced this pull request Nov 19, 2024
…es to other event handlers (Case 177753) (#15)

This adapts
webfactory/WebfactoryWfdMetaBundle#53:

> This PR uses the new API introduced in
symfony/symfony#46001 to read controller
attributes through the `ControllerEvent`, and to make them available to
other event handlers when replacing the controller.
>
> This is necessary when using the `Send304IfNotModified` attribute in
combination with `\Symfony\Component\HttpKernel\Attribute\Cache`.
Without this change,
`\Symfony\Component\HttpKernel\EventListener\CacheAttributeListener`
will not set `Cache` headers accordingly. The result is that you may get
`304 Not Modified` responses on conditional requests with
`If-Modified-Since`, but these are treated as `stale/cache` only in the
HttpCache and have a `Cache-Control: must-revalidate, private` header.

And adds some tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant